import { ApiProperty } from '@nestjs/swagger';

// export enum ErrorCode {
//     ok = 1,
// }

export enum CommonResCode {
  UnknownError = -1,
  Ok = 0,
  NetError = 11,
  TokenError = 13,
  RoleError = 15,
  FileError = 17,
}

export class CommonResponse<T> {
  @ApiProperty({ description: '返回code' })
  readonly code: number = -1;
  @ApiProperty({ description: '返回data' })
  readonly data: T;
  @ApiProperty({ description: '返回消息' })
  readonly msg: string = '';

  constructor(code: number, data: T, msg: string) {
    this.code = code;
    this.data = data;
    this.msg = msg;

    console.log(JSON.stringify(this));
  }
}

export class AppUploadFileDTO {
  @ApiProperty({ required: true, description: '文件id' })
  path: string;

  constructor(path: string) {
    this.path = path;
  }
}
